<%--<%@page import="util.PageObj"%>--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>花卉管理</title>

    <style>
    	*{  /* 居中对齐 */
    		/*  text-align:center;*/
    	}
    	.addflower{
    		text-align:right;
    	}
    	a{
    		text-decoration:none;
    		color:black;
    	}
    	a:hover{
    		color:red;
    	}
    
    	#msg{
    		color:red;
    	}
    	
    </style>
    <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript">
    	$(function(){
    	
    		$("tr:odd").css("background-color","#ccc");
    	
    		$(".del").click(function(){
    			if(!confirm("确定要删除 吗?")){
    				return;
    			}
    		
    			var id = $(this).prop("name");
    			$.get("FlowerServlet?opr=del&id=" + id,null,callback);
    		
    			function callback(data){
    				if(data=="true"){
    					location.reload();
    					alert("删除 成功！");
    				}else{
    					alert("删除失败！");
    				}
    			}
    		
    		});
    	
    	});
    </script>
    </head>
  
  <body>
    	<%
    	 %>
    	 <center>
    	 <table border="1" width="600">
    	 	<tr>
    	 		<td colspan="7">花卉信息列表</td>
    	 	</tr>
    	 	<tr>
    	 		<td colspan="7" class="addflower"><a href="add.jsp">增加花卉</a></td>
    	 	</tr>
    	 	<tr>
    	 		<th>序号</th>
    	 		<th>名称</th>
    	 		<th>花期</th>
    	 		<th>属科</th>
    	 		<th>价格</th>
    	 		<th>产地</th>
    	 		<th>操作</th>
    	 	</tr>
    	 	<c:forEach var="f" items="${pageObj.pageFlowers }">
    	 		<tr>
    	 			<td>${f.id }</td>
    	 			<td>${f.name }</td>
    	 			<td>${f.openDate }</td>
    	 			<td>${f.property }</td>
    	 			<td>${f.price }</td>
    	 			<td>${f.production }</td>
    	 			<td><a href="javascript:void(0);" class="del" name="${f.id }">删除</a></td>
    	 		</tr>
    	 	</c:forEach>  
    	 <tr>
    	 	 <td colspan="7">
    	 	 	当前页：[${pageObj.pageNo}/${pageObj.totalPages}]&nbsp;
    	 	 	 <a href="FlowerServlet?opr=list&page=1">首页</a> &nbsp; 
    	 	 	 <c:if test="${pageObj.pageNo > 1 }">
	    	 	 	<a href="FlowerServlet?opr=list&page=${pageObj.pageNo -1 }">上一页</a> &nbsp; 
	    	 	 </c:if>
	    	 	  <c:if test="${pageObj.pageNo < pageObj.totalPages }">
	    	 	 <a href="FlowerServlet?opr=list&page=${pageObj.pageNo +1 }">下一页</a> &nbsp;
	    	 	  </c:if>
	    	 	 <a href="FlowerServlet?opr=list&page=${pageObj.totalPages}" >末页</a> &nbsp; 
    	 	 </td>
    	 </tr>  	 
</table>
    	 <div id="msg">${msg}
    	 	<% session.removeAttribute("msg"); %>
    	 </div>
    	  </center>
  </body>
</html>
